home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libwmf / api.h next >
Encoding:
C/C++ Source or Header  |  2007-02-16  |  10.9 KB  |  499 lines

  1. /* libwmf (<libwmf/api.h>): library for wmf conversion
  2.    Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources
  3.  
  4.    The libwmf Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public License as
  6.    published by the Free Software Foundation; either version 2 of the
  7.    License, or (at your option) any later version.
  8.  
  9.    The libwmf Library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public
  15.    License along with the libwmf Library; see the file COPYING.  If not,
  16.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.    Boston, MA 02111-1307, USA.  */
  18.  
  19.  
  20. #ifndef LIBWMF_API_H
  21. #define LIBWMF_API_H
  22.  
  23. #include <zlib.h>
  24.  
  25. #include <libwmf/types.h>
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. /**
  32.  * Initializes library
  33.  */
  34. extern wmf_error_t wmf_api_create (wmfAPI**,unsigned long,wmfAPI_Options*);
  35.  
  36. /**
  37.  * Possibly completes output, and otherwise frees all allocated memory
  38.  */
  39. extern wmf_error_t wmf_api_destroy (wmfAPI*);
  40.  
  41. /**
  42.  * Initializes library - 'lite' interface only
  43.  */
  44. extern wmf_error_t wmf_lite_create (wmfAPI**,unsigned long,wmfAPI_Options*);
  45.  
  46. /**
  47.  * Possibly completes output, and otherwise frees all allocated memory - 'lite' interface only
  48.  */
  49. extern wmf_error_t wmf_lite_destroy (wmfAPI*);
  50.  
  51. /**
  52.  * Reads the header of the current metafile
  53.  */
  54. extern wmf_error_t wmf_header_read (wmfAPI*);
  55.  
  56. /**
  57.  * Scans the current metafile to determine bounding box and resources
  58.  */
  59. extern wmf_error_t wmf_scan (wmfAPI*,unsigned long,wmfD_Rect*);
  60.  
  61. /**
  62.  * Plays the current metafile, calling exporter graphics procedures
  63.  */
  64. extern wmf_error_t wmf_play (wmfAPI*,unsigned long,wmfD_Rect*);
  65.  
  66. /**
  67.  * Supplies a width and height for the current metafile
  68.  */
  69. extern wmf_error_t wmf_size (wmfAPI*,float*,float*);
  70.  
  71. /**
  72.  * Supplies a display (integer-) width and height for the current metafile
  73.  */
  74. extern wmf_error_t wmf_display_size (wmfAPI*,unsigned int*,unsigned int*,double,double);
  75.  
  76. /**
  77.  * Sets user defines input stream functions for reading a metafile
  78.  */
  79. extern wmf_error_t wmf_bbuf_input (wmfAPI*,wmfRead,wmfSeek,wmfTell,void*);
  80.  
  81. /**
  82.  * Opens a file as the current metafile
  83.  */
  84. extern wmf_error_t wmf_file_open (wmfAPI*,const char*);
  85.  
  86. /**
  87.  * Closes the file corresponding to the current metafile
  88.  */
  89. extern wmf_error_t wmf_file_close (wmfAPI*);
  90.  
  91. /**
  92.  * Specifies an array of unsigned char as the current metafile
  93.  */
  94. extern wmf_error_t wmf_mem_open (wmfAPI*,unsigned char*,long);
  95.  
  96. /**
  97.  * Disassociates array corresponding to the current metafile
  98.  */
  99. extern wmf_error_t wmf_mem_close (wmfAPI*);
  100.  
  101. /* wmf_stream_create: set FILE stream to 0 to write to memory;
  102.  * wmf_stream_destroy: returns pointer to memory, if not a FILE stream
  103.  */
  104.  
  105. /**
  106.  * Creates compressed character output file stream
  107.  */
  108. extern wmfStream* wmf_ztream_create (wmfAPI*,gzFile);
  109.  
  110. /**
  111.  * Creates uncompressed character output file or memory stream
  112.  */
  113. extern wmfStream* wmf_stream_create (wmfAPI*,FILE*);
  114.  
  115. /**
  116.  * Finalizes compressed character output file stream
  117.  */
  118. extern void wmf_ztream_destroy (wmfAPI*,wmfStream*,char**,unsigned long*);
  119.  
  120. /**
  121.  * Finalizes uncompressed character output file stream
  122.  */
  123. extern void wmf_stream_destroy (wmfAPI*,wmfStream*,char**,unsigned long*);
  124.  
  125. /**
  126.  * Formatted print to character output file stream
  127.  */
  128. extern int wmf_stream_printf (wmfAPI*,wmfStream*,char*,...);
  129.  
  130. /**
  131.  * malloc() & attach to library's memory manager
  132.  */
  133. extern void* wmf_malloc (wmfAPI*,size_t);
  134.  
  135. /**
  136.  * calloc() & attach to library's memory manager
  137.  */
  138. extern void* wmf_calloc (wmfAPI*,size_t,size_t);
  139.  
  140. /**
  141.  * realloc() memory attached to library's memory manager
  142.  */
  143. extern void* wmf_realloc (wmfAPI*,void*,size_t);
  144.  
  145. /**
  146.  * free() memory attached to library's memory manager
  147.  */
  148. extern void wmf_free (wmfAPI*,void*);
  149.  
  150. /**
  151.  * Detach memory from library's memory manager
  152.  */
  153. extern void  wmf_detach (wmfAPI*,void*);
  154.  
  155. /**
  156.  * strdup() & attach to library's memory manager
  157.  */
  158. extern char* wmf_strdup (wmfAPI*,const char*);
  159.  
  160. /**
  161.  * create concatenation of two strings and attach to library's memory manager
  162.  */
  163. extern char* wmf_str_append (wmfAPI*,char*,char*);
  164.  
  165. /**
  166.  * strstr()
  167.  */
  168. extern char* wmf_strstr (const char*,const char*);
  169.  
  170. /**
  171.  * Increases size of API's string buffer; returns new size or 0 on error
  172.  */
  173. extern unsigned long wmf_strbuf_grow (wmfAPI*);
  174.  
  175. /**
  176.  * Initializes the metafile player (called by wmf_api_create())
  177.  */
  178. extern wmf_error_t wmf_player_init (wmfAPI*);
  179.  
  180. /**
  181.  * Returns the Aldus Checksum of the metafile's header
  182.  */
  183. extern U16 wmf_aldus_checksum (wmfAPI*);
  184.  
  185. /**
  186.  * Reads a two-byte sequence from the current metafile, returns U16
  187.  */
  188. extern U16 wmf_read_16 (wmfAPI*);
  189.  
  190. /**
  191.  * Reads a four-byte sequence from the current metafile, returns U32
  192.  */
  193. extern U32 wmf_read_32 (wmfAPI*,U16*,U16*);
  194.  
  195. /**
  196.  * file input (wmf_file_open): fgetc()
  197.  */
  198. extern int wmf_file_read (void*);
  199.  
  200. /**
  201.  * file input (wmf_file_open): fseek()
  202.  */
  203. extern int wmf_file_seek (void*,long);
  204.  
  205. /**
  206.  * file input (wmf_file_open): ftell()
  207.  */
  208. extern long wmf_file_tell (void*);
  209.  
  210. /**
  211.  * memory input (wmf_mem_open): fgetc() equiv.
  212.  */
  213. extern int wmf_mem_read (void*);
  214.  
  215. /**
  216.  * memory input (wmf_mem_open): fseek() equiv.
  217.  */
  218. extern int wmf_mem_seek (void*,long);
  219.  
  220. /**
  221.  * memory input (wmf_mem_open): ftell() equiv.
  222.  */
  223. extern long wmf_mem_tell (void*);
  224.  
  225. /* default ztream functions; NOT to be used directly! */
  226.  
  227. /**
  228.  * compressed char output (wmf_ztream_create): fputs()
  229.  */
  230. extern int wmf_stream_zputs (char*,void*);
  231.  
  232. /**
  233.  * compressed char output (wmf_ztream_create): rewind()
  234.  */
  235. extern int wmf_stream_rezet (void*);
  236.  
  237. /**
  238.  * uncompressed char output (wmf_stream_create): fputs()
  239.  */
  240. extern int wmf_stream_sputs (char*,void*); /* default stream functions; NOT to be used directly! */
  241.  
  242. /**
  243.  * uncompressed char output (wmf_stream_create): rewind()
  244.  */
  245. extern int wmf_stream_reset (void*);
  246.  
  247. /**
  248.  * Writes message to error stream (use WMF_ERROR macro)
  249.  */
  250. extern void wmf_error (wmfAPI*,char*,int,char*);
  251.  
  252. /**
  253.  * Writes message to debug stream (use WMF_DEBUG macro)
  254.  */
  255. extern void wmf_debug (wmfAPI*,char*,int,char*);
  256.  
  257. /**
  258.  * Formatted print to debug stream
  259.  */
  260. extern void wmf_printf (wmfAPI*,char*,...);
  261.  
  262. /**
  263.  * Asserts on zero expression (use WMF_ASSERT macro)
  264.  */
  265. extern void wmf_assert (wmfAPI*,char*,int);
  266.  
  267. /**
  268.  * Outputs library-specific command-line options
  269.  */
  270. extern char* wmf_help (void);
  271.  
  272. /**
  273.  * Sets drawing origin in device coordinates
  274.  */
  275. extern void wmf_set_viewport_origin (wmfAPI*,wmfD_Coord);
  276.  
  277. /**
  278.  * Sets call-back function, called after every metafile record
  279.  */
  280. extern void wmf_status_function (wmfAPI*,void*,wmfStatus);
  281.  
  282. /**
  283.  * Writes to --wmf-write file (which may be WMF or home-made wmfxml)
  284.  */
  285. extern void wmf_write (wmfAPI*,unsigned long,unsigned int,const char*,
  286.                char**,const unsigned char*,unsigned long);
  287.  
  288. /**
  289.  * Open --wmf-write file (which may be WMF or home-made wmfxml)
  290.  */
  291. extern void wmf_write_begin (wmfAPI*,const char*);
  292.  
  293. /**
  294.  * Close --wmf-write file (which may be WMF or home-made wmfxml)
  295.  */
  296. extern void wmf_write_end (wmfAPI*);
  297.  
  298. /**
  299.  * Initialize a wmfAttributes structure
  300.  */
  301. extern void wmf_attr_new (wmfAPI*,wmfAttributes*);
  302.  
  303. /**
  304.  * Clear/Empty a wmfAttributes structure
  305.  */
  306. extern void wmf_attr_clear (wmfAPI*,wmfAttributes*);
  307.  
  308. /**
  309.  * Free memory associated with a wmfAttributes structure
  310.  */
  311. extern void wmf_attr_free (wmfAPI*,wmfAttributes*);
  312.  
  313. /**
  314.  * Add an name&value to a wmfAttributes structure; returns ptr to value-in-list
  315.  */
  316. extern const char * wmf_attr_add (wmfAPI*,wmfAttributes*,const char*,const char*);
  317.  
  318. /**
  319.  * Return value of name in a wmfAttributes structure; returns 0 if name not found
  320.  */
  321. extern const char * wmf_attr_query (wmfAPI*,wmfAttributes*,const char*);
  322.  
  323. /**
  324.  * Load wmfxml file and wmf_mem_open() it
  325.  */
  326. extern wmf_error_t wmf_wmfxml_import (wmfAPI*,const char*);
  327.  
  328. #ifdef __cplusplus
  329. }
  330. #endif
  331.  
  332. /* Useful defs & macros
  333.  */
  334.  
  335. /**
  336.  * @param Z the API handle
  337.  * @param M string to send to the error stream via wmf_error()
  338.  */
  339. #define WMF_ERROR(Z,M) wmf_error (Z,__FILE__,__LINE__,M)
  340.  
  341. #ifdef DEBUG
  342. #define WMF_DEBUG(Z,M) wmf_debug (Z,__FILE__,__LINE__,M)
  343. #define WMF_ASSERT(Z,M) if (!(M)) wmf_assert (Z,__FILE__,__LINE__)
  344. #else
  345. /**
  346.  * @param Z the API handle
  347.  * @param M string to send to the debug stream via wmf_debug()
  348.  * 
  349.  * (debug build only)
  350.  */
  351. #define WMF_DEBUG(Z,M)
  352.  
  353. /**
  354.  * @param Z the API handle
  355.  * @param M an <expr>, if zero then call wmf_assert()
  356.  * 
  357.  * (debug build only)
  358.  */
  359. #define WMF_ASSERT(Z,M)
  360. #endif
  361.  
  362. /* Flags to be passed in wmf_api_create: flags to lie in range (1<<0) to (1<<19)
  363.  */
  364.  
  365. /**
  366.  * Option to wmf_api_create()
  367.  * 
  368.  * use provided [*]alloc/free functions
  369.  */
  370. #define WMF_OPT_ALLOC           (1<<0)
  371.  
  372. /**
  373.  * Option to wmf_api_create()
  374.  * 
  375.  * check provided command line for --wmf-<option>
  376.  */
  377. #define WMF_OPT_ARGS            (1<<1)
  378.  
  379. /**
  380.  * Option to wmf_api_create()
  381.  * 
  382.  * font directories specified
  383.  */
  384. #define WMF_OPT_FONTDIRS        (1<<2)
  385.  
  386. /**
  387.  * Option to wmf_api_create()
  388.  * 
  389.  * font mappings specified
  390.  */
  391. #define WMF_OPT_FONTMAP         (1<<3)
  392.  
  393. /**
  394.  * Option to wmf_api_create()
  395.  * 
  396.  * use system fonts, if found
  397.  */
  398. #define WMF_OPT_SYS_FONTS       (1<<4)
  399.  
  400. /**
  401.  * Option to wmf_api_create()
  402.  * 
  403.  * use specified XML system fontmap file
  404.  */
  405. #define WMF_OPT_SYS_FONTMAP     (1<<5)
  406.  
  407. /**
  408.  * Option to wmf_api_create()
  409.  * 
  410.  * use non-system fonts, if found
  411.  */
  412. #define WMF_OPT_XTRA_FONTS      (1<<6)
  413.  
  414. /**
  415.  * Option to wmf_api_create()
  416.  * 
  417.  * use specified XML non-system fontmap file
  418.  */
  419. #define WMF_OPT_XTRA_FONTMAP    (1<<7)
  420.  
  421. /**
  422.  * Option to wmf_api_create()
  423.  * 
  424.  * use specified ghostscript fontmap file
  425.  */
  426. #define WMF_OPT_GS_FONTMAP      (1<<8)
  427.  
  428. /**
  429.  * Option to wmf_api_create()
  430.  * 
  431.  * write metafile to specified file
  432.  */
  433. #define WMF_OPT_WRITE           (1<<9)
  434.  
  435. /**
  436.  * Option to wmf_api_create()
  437.  * 
  438.  * initialize device-layer with supplied function
  439.  */
  440. #define WMF_OPT_FUNCTION        (1<<10)
  441.  
  442. /**
  443.  * Option to wmf_api_create()
  444.  * 
  445.  * initialize device-layer with specified module
  446.  */
  447. #define WMF_OPT_MODULE          (1<<11)
  448.  
  449. /**
  450.  * Option to wmf_api_create()
  451.  * 
  452.  * check for module also in specified directories
  453.  */
  454. #define WMF_OPT_MODULE_DIRS     (1<<12)
  455.  
  456. /**
  457.  * Option to wmf_api_create()
  458.  * 
  459.  * ignore (some) non-fatal errors --wmf-ignore-nonfatal
  460.  */
  461. #define WMF_OPT_IGNORE_NONFATAL (1<<14)
  462.  
  463. /**
  464.  * Option to wmf_api_create()
  465.  * 
  466.  * suppress all error reports --wmf-error
  467.  */
  468. #define WMF_OPT_NO_ERROR        (1<<15)
  469.  
  470. /**
  471.  * Option to wmf_api_create()
  472.  * 
  473.  * suppress all debug reports --wmf-debug
  474.  */
  475. #define WMF_OPT_NO_DEBUG        (1<<16)
  476.  
  477. /**
  478.  * Option to wmf_api_create()
  479.  * 
  480.  * divert error reports to specified stream
  481.  */
  482. #define WMF_OPT_LOG_ERROR       (1<<17)
  483.  
  484. /**
  485.  * Option to wmf_api_create()
  486.  * 
  487.  * divert debug reports to specified stream
  488.  */
  489. #define WMF_OPT_LOG_DEBUG       (1<<18)
  490.  
  491. /**
  492.  * Option to wmf_api_create()
  493.  * 
  494.  * emit diagnostic information --wmf-diagnostics
  495.  */
  496. #define WMF_OPT_DIAGNOSTICS     (1<<19)
  497.  
  498. #endif /* ! LIBWMF_API_H */
  499.